package org.jeecg.modules.cosmetic.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.modules.cosmetic.handler.ToxicologicalSublistHandler;
import org.jeecg.modules.cosmetic.model.vo.DeleteVO;
import org.jeecg.modules.cosmetic.model.vo.ToxSublistPickVO;
import org.jeecg.modules.cosmetic.model.vo.ToxSublistVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 毒理数据子列表:透皮吸收,急性毒性,刺激性,致敏性,光毒性,致突变性,系统毒性 前端控制器
 * </p>
 *
 * @author lq
 * @since 2024-02-29 13:57:48
 */
@Api(tags = "毒理数据子模块")
@RestController
@RequestMapping("/api/tox/sublist")
public class TToxicologicalSublistController {

    @Resource
    private ISysBaseAPI iSysBaseAPI;

    @Resource
    private ToxicologicalSublistHandler toxicologicalSublistHandler;

    @ApiOperation(value = "子模块查询数据字典值", notes = "子模块查询数据字典值")
    @GetMapping(value = "/get_dict")
    public Result<?> getDictItems(@RequestParam("code") String code) {
        return Result.ok(iSysBaseAPI.getDictItems(code));
    }

    @ApiOperation(value = "保存-更新数据", notes = "保存-更新数据")
    @PostMapping(value = "/save_update")
    public Result<?> saveOrUpdate(@RequestBody List<ToxSublistVO> list) {
        return toxicologicalSublistHandler.saveOrUpdate(list);
    }

    @ApiOperation(value = "查询数据", notes = "查询数据")
    @GetMapping(value = "/get")
    public Result<?> getSublist(@RequestParam("id") Long id, @RequestParam("form") Integer form) {
        return Result.ok(toxicologicalSublistHandler.getSublist(id, form));
    }

    @ApiOperation(value = "查询数据详情", notes = "查询数据详情")
    @GetMapping(value = "/detail")
    public Result<?> getSublistDetail(@RequestParam("id") Long id) {
        return Result.ok(toxicologicalSublistHandler.getSublist(id, null));
    }

    @ApiOperation(value = "查询数据是否为优选", notes = "查询数据是否为优选")
    @GetMapping(value = "/get_pick")
    public Result<?> getSublistPick(@RequestParam("id") Long id, @RequestParam("form") Integer form) {
        return Result.ok(toxicologicalSublistHandler.getSublistPick(id, form));
    }

    @ApiOperation(value = "选择/取消优选", notes = "选择/取消优选")
    @PutMapping(value = "/update_pick")
    public Result<?> updateSublistPick(@RequestBody List<ToxSublistPickVO> voList) {
        return toxicologicalSublistHandler.updateSublistPick(voList);
    }

    @ApiOperation(value = "删除数据", notes = "删除数据")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestBody DeleteVO vo) {
        return Result.ok(toxicologicalSublistHandler.delete(vo.getId()));
    }
}
